﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tank.Properties;//
using System.Drawing;//

namespace Tank
{
    /// <summary>
    /// 角色类（抽象类）
    /// </summary>
    public abstract class Roles : TankMember
    {
        #region 构造函数
        /// <summary>
        /// 构造函数（无参）
        /// </summary>
        public Roles()
        {
        }

        /// <summary>
        /// 构造函数（带参）
        /// </summary>
        /// <param name="x">Tank所处的X坐标</param>
        /// <param name="y">Tank所处的Y坐标</param>
        /// <param name="width">Tank的宽度</param>
        /// <param name="height">Tank的高度</param>
        /// <param name="life">Tank的生命</param>
        /// <param name="sp">Tank的速度</param>
        /// <param name="dir">Tank的方向</param>
        public Roles(int x, int y, int width, int height, int life, int sp, Direction dir)
            : base(x, y, width, height, life, sp, dir)
        {
            this.Hp = 80;
        }
        #endregion

        #region Tank 攻击、登场

        /// <summary>
        /// 射击方法（抽象）
        /// </summary>
        public abstract void Fire();

        /// <summary>
        /// 判断是否被摧毁
        /// </summary>
        public abstract void IsDoom();

        /// <summary>
        /// 调整方向（抽象）
        /// </summary>
        public abstract void AdjustDir();

        /// <summary>
        /// 伤害输出计算
        /// </summary>
        /// <param name="ap"></param>
        /// <param name="dp"></param>
        /// <returns></returns>
        public virtual int HurtClac(Roles a)
        {
            int ap = a.Ap;
            int dp = this.Dp;

            if (ap-dp < 0)
            {
                return Hp;
            }
            this.Hp -= (ap - dp);

            return (Hp<=0)? 0:Hp;
        }

        /// <summary>
        /// 显示角色血量
        /// </summary>
        public virtual void ShowHP(Graphics g)
        {
            g.DrawImage(Resources.HPP, this.X - 10, this.Y - 10, 80, 8);//画出Max血量
            g.DrawImage(Resources.HPG, this.X - 10, this.Y - 10, this.Hp, 8);//画出当前血量
        }

        #endregion

        #region Tank属性（登场时间、是否可操作）

        /// <summary>
        /// 是否可操作
        /// </summary>
        public bool Enable { get; set; }

        /// <summary>
        /// 血量
        /// </summary>
        public int Hp { get; set; }

        /// <summary>
        /// 攻击力
        /// </summary>
        public int Ap { get; set; }

        /// <summary>
        /// 防御力
        /// </summary>
        public int Dp { get; set; }

        #endregion
    }
}
